package com.conv.shop.business.mapper;

import com.conv.shop.business.domain.Product;
import com.conv.shop.business.domain.ProductExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ProductMapper {
    long countByExample(ProductExample example);

    int deleteByExample(ProductExample example);

    int deleteByPrimaryKey(Integer productId);

    int insert(Product record);

    int insertSelective(Product record);

    List<Product> selectByExample(ProductExample example);

    Product selectByPrimaryKey(Integer productId);

    int updateByExampleSelective(@Param("record") Product record, @Param("example") ProductExample example);

    int updateByExample(@Param("record") Product record, @Param("example") ProductExample example);

    int updateByPrimaryKeySelective(Product record);

    int updateByPrimaryKey(Product record);

    @Select("SELECT product_name productName,product_id productId,category_id categoryId,stock_quantity stockQuantity,image_url imageUrl ,is_on_sale isOnSale,price,description from product where product_name like #{productname} limit #{pageNum},#{pageSize} ")
    List<Product> getProductList(@Param("productname")String productname,@Param("pageNum") int pageNum,int pageSize);

    @Select("SELECT product_name productName,product_id productId,category_id categoryId,stock_quantity stockQuantity,image_url imageUrl ,is_on_sale isOnSale,price,description from product where product_name like #{productname}")
    List<Product> getProductByNameLike(@Param("productname")String productname);
}